import time
import functools
from loguru import logger


def timeit(func):
    # @functools.wraps(func)
    def _warp(*args, **kwargs):
        logger.info("func {} start".format(func.__name__))
        start_time = time.time()
        result = func(*args, **kwargs)
        use_time = time.time() - start_time
        logger.info("func {} use time {:.6}".format(func.__name__, use_time))
        return result

    return _warp
